# 导包
from sklearn.neighbors import KNeighborsClassifier,KNeighborsRegressor

# 构建数据
x = [[0],[1],[5],[3]]
# y = [0,0,3,2]
y = [0.1,0.8,3.1,2.8]

# 模型(KNN)
# knn =KNeighborsClassifier(n_neighbors=1)
knn =KNeighborsRegressor(n_neighbors=2)

# 训练
knn.fit(x,y)

# 预测
print(knn.predict([[4]]))